package com.climber.android.commonsdk.helper

import android.os.Bundle
import android.os.Parcelable
import androidx.annotation.Nullable
import java.io.Serializable

/**
 * Created by Mikes at 2019/4/21
 */

class BundleHelper {
    private val bundle: Bundle = Bundle()

    fun putString(@Nullable key: String?, @Nullable value: String?): BundleHelper = this.apply {
        bundle.putString(key, value)
    }

    fun putBoolean(@Nullable key: String?, value: Boolean): BundleHelper = this.apply {
        bundle.putBoolean(key, value)
    }

    fun putDouble(@Nullable key: String?, value: Double): BundleHelper = this.apply {
        bundle.putDouble(key, value)
    }

    fun putInt(@Nullable key: String, value: Int):
            BundleHelper = this.apply {
        bundle.putInt(key, value)
    }

    fun putLong(@Nullable key: String, value: Long):
            BundleHelper = this.apply {
        bundle.putLong(key, value)
    }

    fun putParcelable(@Nullable key: String,@Nullable value: Parcelable?):
            BundleHelper = this.apply {
        bundle.putParcelable(key, value)
    }

    fun putParcelableArrayList(@Nullable key: String, @Nullable value: ArrayList<out Parcelable>?):
            BundleHelper = this.apply {
        bundle.putParcelableArrayList(key, value)
    }

    fun putSerializable(@Nullable key: String,@Nullable value: Serializable?):
            BundleHelper = this.apply {
        bundle.putSerializable(key, value)
    }

    fun putStringArrayList(@Nullable key: String,@Nullable value: ArrayList<String>?):
            BundleHelper = this.apply {
        bundle.putStringArrayList(key, value)
    }

    fun putBundle(@Nullable key: String?, value: Bundle?): BundleHelper = this.apply {
        bundle.putBundle(key, value)
    }

    fun build() : Bundle = bundle
}